<?php
class Template
{
	private $path;
	private $file;
	private $tplVars;

	public function Template($path){
		$this->path = (substr_count($path,".") > 1) ? parseFilePath($path).".tpl" : $path;
		if(!file_exists($this->path))
			throw new Exception(Msg("TEMPLATE_FILE_NOT_EXISTS",$this->path));
		ob_start();
		include($this->path);
		$this->file = addslashes(ob_get_contents());
		ob_end_clean();

	}

	private function parse(){
		foreach($this->tplVars as $key => $value){

		}
	}

	public function assign($name,$content){
		$this->tplVars[$name] = $content;
	}

	public function display(){
		$this->parse();
		$pageHTML = $this->file;
		eval("\$pageHTML=\"$pageHTML\";");
		// send parsed file to the browser
		echo $pageHTML;
	}

	/**
	 * __toString()
	 * Magic method
	 */
	public function __toString(){
		return get_class($this);
	}
}